Test Series - java script

Test Number 13/92

Q: The behaviour of the instances present of a class inside a method is defined by __________
A. Method
B. Classes
C. Interfaces
D. Classes and Interfaces
Solution: Objects of the class are also known as instances of the class. The behaviour of the instance of a class is defined by the class and is shared by all instances.
Q: The keyword or the property that you use to refer to an object through which they were invoked is _________
A. from
B. to
C. this
D. object
Solution: ‘this’ keyword is used to refer to the object through which the properties or methods were invoked. This use of ‘this’ is a fundamental characteristic of the methods of any class.
Q: What will be the output of the following JavaScript code?
var o = new F();
o.constructor === F
A. true
B. false
C. 1
D. 0
Solution: Constructor is a function property of the class which is used to create objects of that class. In the above code, both statements create an instance of the class.
Q: The basic difference between JavaScript and Java is _________
A. There is no difference
B. Functions are considered as fields
C. Variables are specific
D. Functions are values, and there is no hard distinction between methods and fields
Solution: Java is an OOP programming language while JavaScript is an OOP scripting language. The basic difference between JavaScript and Java is that the functions are values, and there is no hard distinction between methods and fields.
Q: The meaning for Augmenting classes is that ___________
A. objects inherit prototype properties even in a dynamic state
B. objects inherit prototype properties only in a dynamic state
C. objects inherit prototype properties in the static state
D. object doesn’t inherit prototype properties in the static state
Solution: JavaScript’s prototype-based inheritance mechanism is dynamic an object inherits properties from its prototype, even if the prototype changes after the object is created. This means that we can augment JavaScript classes simply by adding new methods to their prototype objects.
Q: The property of JSON() method is __________
A. it can be invoked manually as object.JSON()
B. it will be automatically invoked by the compiler
C. it is invoked automatically by the JSON.stringify() method
D. it cannot be invoked in any form
Solution: A common use of JSON is to exchange data to/from a web server. When sending data to a web server, the data has to be a string. In that case json.strigify() is used to convert a javascript object into a string.
Q: When a class B can extend another class A, we say that?
A. A is the superclass and B is the subclass
B. B is the superclass and A is the subclass
C. Both A and B are the superclass
D. Both A and B are the subclass
Solution: Superclass is the class from which subclasses are defined. Subclasses are also called extensions of superclass.therefore in the above scenario A will be superclass and B will be subclass.
Q: If A is the superclass and B is the subclass, then subclass inheriting the superclass can be represented as _________
A. B=inherit(A);
B. B=A.inherit();
C. B.prototype=inherit(A);
D. B.prototype=inherit(A.prototype);
Solution: inherit() function is a predefined function in javascript which is used to inherit properties of another class. The subclass B inherits the prototype of the class A.
Q: The snippet that filters the filtered set is __________
A. var t=new FilteredSet(s, {function(s) {return !(x instanceof Set);});
B. var t=new FilteredSet{function(s) {return !(x instanceof Set);});
C. var t=new FilteredSet(s, {function(s) {return (x instanceof Set);});
D. var t=new FilteredSet(s, {function(s) {return x;});
Solution: The instanceof operator is used to check the type of an object at run time. The instanceof operator returns a boolean value that indicates if an object is an instance of a particular class.
Q: The method that can be used to create new properties and also to modify the attributes of existing properties is _________
A. Object.defineProperty()
B. Object.defineProperties()
C. Both Object.defineProperty() and Object.defineProperties()
D. Object.inherit()
Solution: The method Object.defineProperty() defines a new property directly on an object, or modifies an existing property on an object, and returns the object.Both Object.defineProperty() and Object.defineProperties() can be used todefine new properties.

You Have Score    /10